package wyj;

import java.util.Scanner;
import java.util.regex.Pattern;

public class lll222 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        sc.nextLine();
        while(m--!= 0)
        {
            String s = sc.nextLine();
            if(s.length()<8 || s.length()>16)
            {
                System.out.println("NO");
                continue;
            }
            int count = 0;
            if(Pattern.compile("[A-Z]").matcher(s).find())
            {
                count++;
            }
            if(Pattern.compile("[a-z]").matcher(s).find())
            {
                count++;
            }
            if(Pattern.compile("[0-9]").matcher(s).find())
            {
                count++;
            }
            if(Pattern.compile("[~!@#$%^]").matcher(s).find())
            {
                count++;
            }
            System.out.println(count >2 ? "Yes":"NO");
        }

    }


}
